﻿function TIO() {
    this.post = function(pURL, pOntion, pFuncName) {
        $.post(pURL, pOntion, pFuncName);
    }

    this.ajax = function (pURL, pData) {
        var str = '';
        $.ajax({
            url: pURL,
            async: false,
            type: "POST",
            data: pData,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                str = data;
            },
            error: function (err) {
                console.log(err);
            }
        });
        return str;
    }
    this.ajaxGet = function (pURL, pData) {
        var result = null;
        $.ajax({
            url: pURL,
            async: false,
            cache: true,
            type: "get",
            data: pData,
            contentType: "text/xml; charset=utf-8",
            dataType: "xml",
            success: function (data) {
                result = $(data).find('string').text();
            },
            error: function (err) {
                console.log(err);
            }
        });
        return result;
    }
    this.ajaxGetHandle = function (pURL, pData) {
        var result = null;
        $.ajax({
            url: pURL,
            async: false,
            cache: true,
            type: "get",
            data: pData,
            contentType: "text/xml; charset=utf-8",
            dataType: "text",
            success: function (data) {
                result = data;
            },
            error: function (err) {
            }
        });
        return result;
    }
    this.ajaxDelegate = function (pURL, pData, pFuncName, controlID, paraControl) {
        $.ajax({
            url: pURL,
            async: true,
            type: "POST",
            data: pData,
            success: function (data) {
                var sFunction = pFuncName + '(data, controlID, paraControl)';
                eval(sFunction);
            },
            error: function (err) {
            }
        });
   }
}